<?php
namespace Admin\Controller;
use Think\Controller;
class CommentsController extends BaseController{
    public function commentslist(){
        /*尹京华--显示评论列表方法*/
        $commentsmodel =M('comments'); 
        $pageSize=10;//每页显示的数据个数
        $records=$commentsmodel->count(); //查询数据表中数据的总个数
        $Page = new \Think\Page($records,$pageSize);//实例化分页类，传入总数和每页显示的数量
        $list=$commentsmodel->order('comments_id asc')->limit($Page->firstRow,$pageSize)->select();//进行分页数据查询
        // dump($list);
        // exit();
        //$comments=$commentsmodel->order('comments_id asc')->select();
        //$this->comments=$comments;
        $page1=$Page->show();//分页显示输出
        $this->assign(array('comments'=>$list,'page1'=>$page1));//用数组的方式赋值数据集，赋值分页输出
        $this->display();//输出模板

       
       
       /* $this->link=$Page->show();
        $this->qrcodeList=$goods->where($goodsData)->order("id desc")->limit($Page->firstRow,$pageSize)->select();*/
    }

    public function commentsdel($comments_id){
        /*尹京华--删除评论接口*/
        $commentsmodel=M('comments');
        // $comments=$commentsmodel->where("comments_id=$comments_id")->find();
        if (false !== $commentsmodel->where("comments_id=$comments_id")->delete())
        {
            $this->success('删除成功！',U('Comments/commentslist'),3);
        } else {
            $this->error('删除失败 ');
        }

    }

    public function scomments($comments_content){
        /*尹京华--搜索评论方法*/
       $commentsmodel =M('comments');
        $comments=$commentsmodel->query("select * from comments where comments_content LIKE '%$comments_content%'");
        $this->comments=$comments;
        $this->display(); 
    } 
}
?>